#include "Comm.hpp"
#include"Fifo.hpp"
#include<unistd.h>
int main()
{
    key_t key = Getshmkeyordie();
    std::cout << "key:" << key << std::endl;

    int shmid = Getshm(key,defaultsize);
    std::cout<<"shmid:"<<shmid<<std::endl;


    char *addr = (char*)ShmAttach(shmid);
    std::cout<<"Attach shm success,addr:"<<ToHex((uint64_t)addr)<<std::endl;


    memset(addr,0,defaultsize);
     Sync syn;
     syn.OpenReadOrDie();
     for(char c = 'A';c<='Z';c++)
     {
        addr[c-'A'] = c;
        sleep(1);
        syn.Wakeup();
     }
     ShmDetach(addr);
     std::cout<< " Detach shm success,addr:"<<ToHex((uint64_t)addr)<<std::endl;
     sleep(5);

    return 0;
}